<?php

namespace app\modules\hr\modules\position\controllers;
use app\controllers\BaseController;
use app\data\PositionData;

class DefaultController extends BaseController
{

	private $_positionManager;

	public function init(){
		parent::init();
		$this->_positionManager = \YII::$app->mydi->get("app\lib\logic\PositionLogicInterface");
	}

	/**
	 * 用於 select 控件的數據
	 * @return array  json
	 */
	public function actionGetselectall(){
		$list = $this->_positionManager->getAll([]);
		return $this->renderJson(PositionData::toSelectData($list));
	}

	/**
	 * 根据UnitID 查询select 控件数据
	 * @return [type] [description]
	 */
	public function actionGetselectallbyunitid(){
		$unitId = \YII::$app->request->get("unit_id");

		$list = $this->_positionManager->getAll(["unit_id"=>$unitId]);
		
		return $this->renderJson(PositionData::toSelectData($list));
	}

}
